package lib.gui;

import java.io.File;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;

import lib.Base.Message;
import lib.Common.Cast;
import lib.Common.Path;

import org.swixml.SwingEngine;

public class GuiProfileGuestbook {
	/**
	 * Class which represents a guestbook entry in the profile page
	 */
	
	private JTextArea text;
	private JLabel user;
	private JLabel date;

	public GuiProfileGuestbook(Message message) {

		try {
			new SwingEngine(this).render(new File(Path.GUI_PATH
					+ "gui-profile-guestbook.xml")).setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}

		this.text.setText(message.getText());
		this.user.setText(message.getUserId());
		this.date.setText(Cast.formatTimeStampAs_ddmmyyyy(message
				.getTimestamp()));
	}
	
	public JComponent getPanel(){
		return (JPanel)user.getParent();
	}
}